package org.anyfiles.digest;

import java.security.NoSuchAlgorithmException;

public class DigestFactory {

	public static String DIGEST_MD5 = "MD5";
	public static String DIGEST_SHA = "SHA";

	private DigestFactory() {
	}

	public static IDigest getInstance(String digestName) throws NoSuchAlgorithmException {
		if(null == digestName) {
			throw new NullPointerException("digestName is null");
		} else if("".equals(digestName)) {
			throw new IllegalArgumentException("digestName is \"\"");
		} else if(DIGEST_MD5.equals(digestName)) {
			return new MD5Digest();
		} else if(DIGEST_SHA.equals(digestName)) {
			return new SHADigest();
		}
		throw new NoSuchAlgorithmException("digestName not available");
	}
}
